//
// Created by v on 2021/8/7.
//

#include <stdio.h>
#include "cm_image_quality.h"

#include "CMCommandLineParser.h"

static const char *keys = "{ t | | which operation to do (fuzzy)}"
                          "{ img_file | | which file to check }"
                          "{ help | | help message }";

void test_image_fuzzy(const char *file)
{
    CMImageQuality quality(file);
    quality.checkFuzzy();
}

void test_image_keepout(const char *file)
{
    CMImageQuality quality(file);
    int count = quality.checkKeepOut();
    printf("has keep out area count [%d]\n", count);
}

void test_simple(const char *file)
{
    CMImageQuality quality(file);
    quality.simpleTest();
}

int main(int argc, char **args)
{
    printf("Startup\n");
    CommandLineParser parser(argc, args, keys);
    if (parser.has("help"))
    {
        parser.printMessage();
        return 0;
    }

    std::string file = parser.get<std::string>("img_file");
    std::string type = parser.get<std::string>("t");
    if (type == "fuzzy")
    {
        test_image_fuzzy(file.c_str());
    }
    else if (type == "keepout")
    {
        test_image_keepout(file.c_str());
    }
    else if (type == "test")
    {
        test_simple(file.c_str());
    }
    else
    {
        printf("Unsupported [%s]\n", file.c_str());
    }

    printf("Done\n");

    return 0;
}
